org.neo4j.index.lucene
Class LuceneFulltextIndexService

java.lang.Object
  extended by org.neo4j.index.impl.GenericIndexService
      extended by org.neo4j.index.lucene.LuceneIndexService
          extended by org.neo4j.index.lucene.LuceneFulltextIndexService
All Implemented Interfaces:
IndexService
Direct Known Subclasses:
LuceneFulltextQueryIndexService

public class LuceneFulltextIndexService
extends LuceneIndexService

A LuceneIndexService which indexes the values with fulltext indexing. Fulltext means that the indexing process takes the values you throw in and tokenizes those into words so that you can query for those individual words in getNodes(String, Object). Also queries are case-insensitive. It stores more data per Lucene entry to make this possible. This makes it incompatible with LuceneIndexService so it has got its own XA resource ID. This means that you can have one LuceneIndexService and one LuceneFulltextIndexService for a GraphDatabaseService. See more information at http://wiki.neo4j.org/content/Indexing_with_IndexService#Fulltext_indexing


Field Summary
protected static String DOC_INDEX_SOURCE_KEY
           
protected static String FULLTEXT_DIR_NAME_POSTFIX
           
 
Fields inherited from class org.neo4j.index.lucene.LuceneIndexService
DEFAULT_LAZY_SEARCH_RESULT_THRESHOLD, DIR_NAME, DOC_ID_KEY, DOC_INDEX_KEY
 
Constructor Summary
LuceneFulltextIndexService(org.neo4j.graphdb.GraphDatabaseService graphDb)
           
 
Method Summary
 void enableCache(String key, int maxNumberOfCachedEntries)
          Enables an LRU cache for a specific index (specified by key) so that the maxNumberOfCachedEntries number of results found with LuceneIndexService.getNodes(String, Object) are cached for faster consecutive lookups.
protected  org.apache.lucene.search.Query formQuery(String key, Object value, Object matching)
           
protected  Class<? extends LuceneDataSource> getDataSourceClass()
           
protected  String getDirName()
           
 IndexHits<org.neo4j.graphdb.Node> getNodes(String key, Object value)
          Since this is a "fulltext" index it changes the contract of this method slightly.
 IndexHits<org.neo4j.graphdb.Node> getNodesExactMatch(String key, Object value)
          Does a getNodes(String, Object) using exact matching, so that it for this call behaves like LuceneIndexService.
 org.neo4j.graphdb.Node getSingleNodeExactMatch(String key, Object value)
          A method for calling LuceneIndexService.getSingleNode(String, Object) using exact matching.
protected  byte[] getXaResourceId()
           
 
Methods inherited from class org.neo4j.index.lucene.LuceneIndexService
getEnabledCacheSize, getLazySearchResultThreshold, getNodes, getNodes, getSingleNode, getSingleNode, index, indexThisTx, instantiateIdToNodeIterator, removeIndex, removeIndex, removeIndexThisTx, setLazySearchResultThreshold, shutdown
 
Methods inherited from class org.neo4j.index.impl.GenericIndexService
beginTx, getGraphDb, removeIndex
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DOC_INDEX_SOURCE_KEY

protected static final String DOC_INDEX_SOURCE_KEY
See Also:
Constant Field Values

FULLTEXT_DIR_NAME_POSTFIX

protected static final String FULLTEXT_DIR_NAME_POSTFIX
See Also:
Constant Field Values
Constructor Detail

LuceneFulltextIndexService

public LuceneFulltextIndexService(org.neo4j.graphdb.GraphDatabaseService graphDb)
Parameters:
graphDb - the GraphDatabaseService to use.
Method Detail

getDataSourceClass

protected Class<? extends LuceneDataSource> getDataSourceClass()
Overrides:
getDataSourceClass in class LuceneIndexService

getDirName

protected String getDirName()
Overrides:
getDirName in class LuceneIndexService

getXaResourceId

protected byte[] getXaResourceId()
Overrides:
getXaResourceId in class LuceneIndexService

getNodes

public IndexHits<org.neo4j.graphdb.Node> getNodes(String key,
                                                  Object value)
Since this is a "fulltext" index it changes the contract of this method slightly. It treats the value more like a query in than you can query for individual words in your indexed values. So if you've indexed node (1) with value "Andy Wachowski" and node (2) with "Larry Wachowski" you can expect this behaviour if you query for:

Specified by:
getNodes in interface IndexService
Overrides:
getNodes in class LuceneIndexService
Parameters:
key - the key for index
value - the value for index
Returns:
nodes that have been indexed with key and value

getNodesExactMatch

public IndexHits<org.neo4j.graphdb.Node> getNodesExactMatch(String key,
                                                            Object value)
Does a getNodes(String, Object) using exact matching, so that it for this call behaves like LuceneIndexService.

Overrides:
getNodesExactMatch in class LuceneIndexService
Parameters:
key - the key.
value - the query.
Returns:
the result of the query.

getSingleNodeExactMatch

public org.neo4j.graphdb.Node getSingleNodeExactMatch(String key,
                                                      Object value)
Description copied from class: LuceneIndexService
A method for calling LuceneIndexService.getSingleNode(String, Object) using exact matching. For this class it's equivalent to calling LuceneIndexService.getSingleNode(String, Object), but for subclasses, such as LuceneFulltextIndexService it is useful for it to be able to do queries with exact matching, even though it's a fulltext index.

Overrides:
getSingleNodeExactMatch in class LuceneIndexService
Parameters:
key - the index to search in.
value - the value to match hits for.
Returns:
the single node for the query, or null if no hit found. If more than one hit was found a RuntimeException is thrown.

formQuery

protected org.apache.lucene.search.Query formQuery(String key,
                                                   Object value,
                                                   Object matching)
Overrides:
formQuery in class LuceneIndexService
Parameters:
key - the key
value - the value
matching - an object describing what kind of matching to do. The type this object is is solely up to the implementation.
Returns:
the Query formed from key/value.

enableCache

public void enableCache(String key,
                        int maxNumberOfCachedEntries)
Description copied from class: LuceneIndexService
Enables an LRU cache for a specific index (specified by key) so that the maxNumberOfCachedEntries number of results found with LuceneIndexService.getNodes(String, Object) are cached for faster consecutive lookups. It's preferred to enable cache at construction time.

Overrides:
enableCache in class LuceneIndexService
Parameters:
key - the index to enable cache for.
maxNumberOfCachedEntries - the max size of the cache before old ones are flushed from the cache.


Copyright © 2010 Neo4j. All Rights Reserved.